// addHandler
function addHandler(node, type, handler) {
    function wrapHandler(event) {
        handler(normalizeEvent(event || window.event));
    }
    registerEventHandler(node, type, wrapHandler);
    return {node: node, type: type, handler: wrapHandler};
}

function removeHandler(object) {
    unregisterEventHandler(object.node, object.type, object.handler);
}


// registerEventHandler
function registerEventHandler(node, event, handler) {
  if (typeof node.addEventListener == "function")
    node.addEventListener(event, handler, false);
  else
    node.attachEvent("on" + event, handler);
}

function unregisterEventHandler(node, event, handler) {
  if (typeof node.removeEventListener == "function")
    node.removeEventListener(event, handler, false);
  else
    node.detachEvent("on" + event, handler);
}

// note that you have to click on the bottom right of the screen
// to hit the frame that this script runs in
/*
registerEventHandler(document.body, "click", function(event) {
  event = event || window.event;
  console.log(event.clientX, ",", event.clientY);
});
*/
